const mysql = require("mysql")

let connection = mysql.createConnection({
    host: "localhost",
    port: 3306,
    user: "root",
    password: "root",
    database: "message_board"
})

connection.connect()
function query(sql,data) {
    return new Promise((reslove, reject) => {
        connection.query(sql, data, function (error, result) {
            if (error) {
                reject(error)
            } else {
                reslove(result)
            }
        })
    })
}

module.exports = {
    query
}